package logic

import (
	"C/renrenzhuC_srv/model/mysql"
	"context"

	"C/renrenzhuC_srv/internal/svc"
	"C/renrenzhuC_srv/renrenzhuC"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsRankLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsRankLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsRankLogic {
	return &GoodsRankLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsRankLogic) GoodsRank(in *renrenzhuC.GoodsRankRequest) (*renrenzhuC.GoodsRankResponse, error) {
	// todo: add your logic here and delete this line
	g := mysql.Goods{}
	list := g.List10()
	var good []*renrenzhuC.GoodsList
	for _, i2 := range list {
		good = append(good, &renrenzhuC.GoodsList{
			Title:  i2.Title,
			Price:  float32(i2.Price),
			Cover:  i2.Cover,
			Stock:  int64(i2.Stock),
			Status: i2.Status,
			Likes:  i2.Likes,
			Type:   i2.Type,
		})
	}
	return &renrenzhuC.GoodsRankResponse{List: good}, nil
}
